<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

/**
 * iframe 窗口调用父窗口：parent.functionName();
 * @param $data             弹窗信息
 * @param string $type      弹出框的类型
 * @param bool $is_reload   是否刷新
 * @param string $url       新页面打开地址
 * @param
 */
function php_alert($data,$type = 'error', $is_reload = false, $url = ''){
    if(empty($url) && !$is_reload){
        echo "<script>parent.my_alert('$data','$type')</script>";
        die;
    }else if (empty($url) && $is_reload){
        echo "<script>parent.my_alert('$data','$type',function() {parent.location.reload();})</script>";
    }else{
        echo "<script>parent.my_alert('$data','$type',function() {parent.location.href = '$url';})</script>";
        die;
    }
}

/**
2  * 自定义tp自带的跳转提示页;
3  * @param data                      弹窗信息
4  * @param string $type             弹出框的类型
5  * @param string callable          新页面打开地址
6  */
function alert_msg($text='',$type='error',$callback=''){
    echo '<meta charset="utf-8" /><link href="/public/static/common/css/sweetalert.min.css" rel="stylesheet"><script src="/public/static/admin/js/jquery_002.js"></script><script type="text/javascript" src="/public/static/common/js/sweetalert.min.js"></script> <script src="/public/static/admin/js/my_config.js"></script>';
    echo "<script>window.οnlοad=function () {my_alert('$text','$type',function() {location.href = '$callback';})}</script>";
    die;
}